//
//  YxrInputView.swift
//  YXRSmartDeviceDemo
//
//  Created by run on 2024/7/1.
//

import SwiftUI

struct YxrInputView: View {
    let title: String
    let placeholderText: String
    @Binding var text: String

    init(_ title: String, placeholderText: String = "请输入", text: Binding<String>) {
        self.title = title
        self.placeholderText = placeholderText
        _text = text
    }

    var body: some View {
        HStack {
            Text(title)
                .font(.body)
                .foregroundColor(.secondary)
                .frame(minWidth: 80, alignment: .leading)
            TextField(placeholderText, text: $text) {
                debugPrint("\(title): \(self.text)")
                // MainApp.keyWindow?.endEditing(true)
            }
            .disableAutocorrection(true)
        }
        .font(.caption)
        .frame(height: 50)
        .textFieldStyle(RoundedBorderTextFieldStyle())
        .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20))
    }
}
